# 定义要匹配的字符串列表
match_strings = ['====getMatrix获取数据耗时']


def read_log(file_path):
    # 打开文件并逐行读取内容
    with open(file_path, 'r', encoding='utf-8') as file:
        for line in file:
            # 去除行末的换行符
            line = line.strip()
            print(line)
            # 检查行是否包含任何一个匹配字符串
            if any(match in line for match in match_strings):
                # print(line)
                # 从日志字符串中提取耗时后面的数字
                parts = line.split("耗时：")
                if len(parts) > 1:
                    # 获取耗时后面的字符串
                    time_part = parts[1].split(",")[0]
                    # 转换为整数
                    time_duration = int(time_part)
                    print(line)
                    if time_duration > 1000:
                        print(line)
                        # print(f"耗时: {time_duration}ms")
                    # print(f"耗时: {time_duration}")
                else:
                    print("未找到耗时信息")


if __name__ == '__main__':
  #  read_log('business (2).log')
  # read_log('business.log')
  read_log('business (3).log')